#ifndef INCLUDE_H
#define INCLUDE_H

#include <math.h>
//#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <tgmath.h>

#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <termio.h>
#include <sys/msg.h>
#include <errno.h>
#include <sys/shm.h>

#include "timer.h"

#include "Define.h"

#include "Struct.h"


//#include "fpga_dummy.h"

#include "Diag.h"
#include "Startup1.h"
#include "Mainfunc.h"
#include "Scc.h"
#include "Ctrlfunc.h"
#include "Control.h"

#include "Ebcmd.h"
#include "Tod.h"
#include "Status.h"
#include "Command.h"
#include "Navicmd.h"
#include "Switch.h"

#include "Log.h"
#include "Config.h"

#include "Ocxo.h"

#include "Trace.h"
#include "Holdover.h"
#include "Recovery.h"

#include "Ctrlmon.h"

#include "Main.h"
#include "Version.h"
#include "Matrix.h"
#include "Pll.h"
#include "Dual.h"
#include "Counter.h"

#include "Odtcmd.h"

#include "Eb.h"

#include "Rtc.h"

#include "Led.h"

#include "E1.h"
#include "RB.h"
#include "Extern.h"

#include "LMU.h"

#include "Offset.h"

#include "Cmd.h"



//---------------------------------
#define IOCTL_GPIO_PID_IN		12
#define IOCTL_ADC_GET_VAL 		13
#define IOCTL_OCXO_TEMP			14
#define IOCTL_BOARD_TEMP		15
#define IOCTL_TEMP_CONFIG		16

#define IOCTL_PCK1_ENABLE		19
//---------------------------------



//--------------------------
#define WARM_START_BOOTING	0
#define WARM_START_UPDATE	1
#define WARM_START_APPLY	2

#define	M_SECTION_ALL			1
#define	M_SECTION_CODE			2
#define	M_SECTION_ZEROVARS		3
#define	M_SECTION_VARS			4
#define	M_SECTION_STRINGS		5
#define	M_SECTION_RANDOM		6

#define	LSR_THRE 0



#define printf0(x); 0; 
#define printf1(x,y); 0;
#define printf2(x,y1,y2); 0;
#define printf3(x,y1,y2,y3); 0;
#define printf4(x,y1,y2,y3,y4); 0;
#define printf5(x,y1,y2,y3,y4,y5); 0;
#define printf6(x,y1,y2,y3,y4,y5,y6); 0;
#define printf7(x,y1,y2,y3,y4,y5,y6,y7); 0;
#define printf8(x,y1,y2,y3,y4,y5,y6,y7,y8); 0;

#define read_memory_start(x,y1,y2); 0;


#define Enable1PPSOut() 0
#define WarmStart(x) 0
#define read_memory(x) 0
#define SetDebugPortTx() 0

int WarmupTimeCounter;


int TCR2;
int U1THR;
int U1LSR;
int U0THR;
int U0LSR;



int prev_running_time, prev_power_time;
//---------------------------
#define cmd_msg_buf_size 1024

typedef struct {
	long mtype;
	int  len;
	unsigned char data[cmd_msg_buf_size];
//can have more
} cmd_msg;

#define CMD_MSG_SIZE	( sizeof( cmd_msg ) - sizeof( long ) )  //minus sizeof cmd_msg.mtype

#define MSGQid0Path					"/etc/ipc/msgQid0"
//#define MSGQid0Path		"/etc/msg/msgQid0"
extern key_t msgQkey0;
extern int msgQid0;

typedef struct {
	long mtype;
	unsigned short year;
	unsigned char month;
	unsigned char day;
	unsigned char hour;
	unsigned char minute;
	unsigned char second;
	unsigned char leap_pending;
} que2_tod;

#define QUE2_SIZE_ALL (sizeof(que2_tod)-sizeof(long))

#define MSGQid2Path		"/gpsclock/msgQid2"


#endif

